import './App.less';
import 'antd/dist/antd.css';

import { ConfigProvider } from 'antd';
import zhCN from 'antd/lib/locale/zh_CN';
import { observer } from 'mobx-react';
import { useContext } from 'react';
import { useRoutes } from 'react-router-dom';
import { useMount } from 'react-use';

import RootStore from '@/store/root';

// @ts-ignore
// import { ThemeEnum } from '@@/components/style/context';
// @ts-ignore
// import { loadTheme } from '@@/components/style/themes';
import routes from './route';

// loadTheme(ThemeEnum.light);

function App() {
  const root = useContext(RootStore);
  useMount(async () => {
    await root.userStore.fetchUser();
  });

  // const routing = useRoutes(routes(root.isLoggedIn));
  const routing = useRoutes(routes(true));

  return <ConfigProvider locale={zhCN}>{routing}</ConfigProvider>;
}

export default observer(App);
